package main

import (
	"fmt"
	"math/rand"
	"time"
)

/*
用来查询是否逃逸 逃逸分析由编译器完成，作用于编译阶段
go build -gcflags=-m 变量逃逸.go
*/
func generate8191() {
	nums := make([]int, 8192) // < 64KB
	for i := 0; i < 8191; i++ {
		nums[i] = rand.Int()
		//fmt.Println(nums[i])
	}
}

func generate8192() {
	nums := make([]int, 8192) // = 64KB
	for i := 0; i < 8192; i++ {
		nums[i] = rand.Int()
		//fmt.Println(nums[i])
	}
}

func generate8193() {
	nums := make([]int, 8193) // = 64KB
	for i := 0; i < 8193; i++ {
		nums[i] = rand.Int()
		//fmt.Println(nums[i])
	}
}

func generate(n int) {
	nums := make([]int, n) // 不确定大小
	for i := 0; i < n; i++ {
		nums[i] = rand.Int()
		fmt.Println(nums[i])
	}
}

func main() {
	rand.Seed(time.Now().Unix())
	fmt.Println(rand.Int())
	generate8191()
	generate8192()
	generate8193()
	generate(1)
}
